package org.finesys.common.security.authorization;

import org.finesys.common.security.authentication.gitee.OAuth2GiteeAuthenticationConverter;
import org.finesys.common.security.authentication.password.OAuth2ResourceOwnerPasswordAuthenticationConverter;
import org.finesys.common.security.authentication.sms.OAuth2ResourceOwnerSmsAuthenticationConverter;
import org.springframework.security.oauth2.server.authorization.web.authentication.*;
import org.springframework.security.web.authentication.AuthenticationConverter;

import java.util.Arrays;
import java.util.List;

public interface AccessTokenRequestConverterCustomizer {

    List<AuthenticationConverter> CONVERTER_LIST = Arrays.asList(
            //自定义的gitee oauth2登录
            new OAuth2GiteeAuthenticationConverter(),
            //自定义密码
            new OAuth2ResourceOwnerPasswordAuthenticationConverter(),
            //自定义验证码方式
            new OAuth2ResourceOwnerSmsAuthenticationConverter(),
            //内置刷新
            new OAuth2RefreshTokenAuthenticationConverter(),
            //内置客户端
            new OAuth2ClientCredentialsAuthenticationConverter(),
            //内置授权码
            new OAuth2AuthorizationCodeAuthenticationConverter(),
            //内置的授权码请求
            new OAuth2AuthorizationCodeRequestAuthenticationConverter()
    );

    static AuthenticationConverter customizer() {
        return new DelegatingAuthenticationConverter(CONVERTER_LIST);
    }
}
